package com.atguigu.paymentdemo.controller;

import com.atguigu.paymentdemo.service.impl.WxNavicateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: payment-demo
 * @package: com.atguigu.paymentdemo.controller
 * @className: WxNativeController
 * @author: 躺着认真玩
 * @description: 微信native接口
 * @date: 2025/6/9 16:51
 * @version: 1.0
 */
@RestController
@RequestMapping()
public class WxNativeController {
    @Autowired
    private WxNavicateService wxNavicateService;
    @PostMapping("/wechatpay/notify")
    public ResponseEntity<String> handleWeChatPayNotification(
            @RequestBody String requestBody,
            @RequestHeader("Wechatpay-Signature") String wechatSignature,
            @RequestHeader("Wechatpay-Serial") String wechatPaySerial,
            @RequestHeader("Wechatpay-Nonce") String wechatpayNonce,
            @RequestHeader("Wechatpay-Timestamp") String wechatTimestamp){
        return wxNavicateService.handleWeChatPayNotification(requestBody,
                wechatSignature,wechatPaySerial,wechatpayNonce,wechatTimestamp);
    }

    @PostMapping("/wechatpay/refund/notify")
    public ResponseEntity handleWeChatRefundNotification(
            @RequestBody String requestBody,
            @RequestHeader("Wechatpay-Signature") String wechatSignature,
            @RequestHeader("Wechatpay-Serial") String wechatPaySerial,
            @RequestHeader("Wechatpay-Nonce") String wechatpayNonce,
            @RequestHeader("Wechatpay-Timestamp") String wechatTimestamp){
        return wxNavicateService.handleWeChatRefundNotification(requestBody,
                wechatSignature,wechatPaySerial,wechatpayNonce,wechatTimestamp);
    }
}
